package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.annotation.UserContext;
import com.ruoyi.system.domain.vo.UserData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbTableQrcodeAssociationMapper;
import com.ruoyi.system.domain.TbTableQrcodeAssociation;
import com.ruoyi.system.service.ITbTableQrcodeAssociationService;

/**
 * 桌号管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-12
 */
@Service
public class TbTableQrcodeAssociationServiceImpl implements ITbTableQrcodeAssociationService 
{
    @Autowired
    private TbTableQrcodeAssociationMapper tbTableQrcodeAssociationMapper;

    /**
     * 查询桌号管理
     * 
     * @param associationId 桌号管理主键
     * @return 桌号管理
     */
    @Override
    public TbTableQrcodeAssociation selectTbTableQrcodeAssociationByAssociationId(Long associationId)
    {
        return tbTableQrcodeAssociationMapper.selectTbTableQrcodeAssociationByAssociationId(associationId);
    }

    /**
     * 查询桌号管理列表
     * 
     * @param tbTableQrcodeAssociation 桌号管理
     * @return 桌号管理
     */
    @Override
    public List<TbTableQrcodeAssociation> selectTbTableQrcodeAssociationList(TbTableQrcodeAssociation tbTableQrcodeAssociation)
    {
        UserData userData = UserContext.getUserData();
        tbTableQrcodeAssociation.setMerchantId((long)userData.getMerchantId());
        tbTableQrcodeAssociation.setStoreId((long)userData.getStoreId());
        try {
            return tbTableQrcodeAssociationMapper.selectTbTableQrcodeAssociationList(tbTableQrcodeAssociation);
        }finally {
            UserContext.clear();
        }
    }

    /**
     * 新增桌号管理
     * 
     * @param tbTableQrcodeAssociation 桌号管理
     * @return 结果
     */
    @Override
    public int insertTbTableQrcodeAssociation(TbTableQrcodeAssociation tbTableQrcodeAssociation)
    {
        UserData userData = UserContext.getUserData();
        tbTableQrcodeAssociation.setMerchantId((long)userData.getMerchantId());
        tbTableQrcodeAssociation.setStoreId((long)userData.getStoreId());
//        System.out.println(tbTableQrcodeAssociation.getMerchantId() + " ：新增=========================================");
        try {
            return tbTableQrcodeAssociationMapper.insertTbTableQrcodeAssociation(tbTableQrcodeAssociation);
        }finally {
            UserContext.clear();
        }
    }

    /**
     * 修改桌号管理
     * 
     * @param tbTableQrcodeAssociation 桌号管理
     * @return 结果
     */
    @Override
    public int updateTbTableQrcodeAssociation(TbTableQrcodeAssociation tbTableQrcodeAssociation)
    {
        return tbTableQrcodeAssociationMapper.updateTbTableQrcodeAssociation(tbTableQrcodeAssociation);
    }

    /**
     * 批量删除桌号管理
     * 
     * @param associationIds 需要删除的桌号管理主键
     * @return 结果
     */
    @Override
    public int deleteTbTableQrcodeAssociationByAssociationIds(Long[] associationIds)
    {
        return tbTableQrcodeAssociationMapper.deleteTbTableQrcodeAssociationByAssociationIds(associationIds);
    }

    /**
     * 删除桌号管理信息
     * 
     * @param associationId 桌号管理主键
     * @return 结果
     */
    @Override
    public int deleteTbTableQrcodeAssociationByAssociationId(Long associationId)
    {
        return tbTableQrcodeAssociationMapper.deleteTbTableQrcodeAssociationByAssociationId(associationId);
    }
}
